<?php

use Illuminate\Database\Seeder;

class AdminPanelSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        \App\B2BProject\Admin\AdminPanelNav::truncate();

        $nav = [
             [
                'name'     => 'setting',
                'icon'     => 'am-icon-gear',
                'children' => [
                    ['name' => 'site-setting', 'icon' => 'am-icon-home', 'route' => 'admin.site-setting.index'],
//                    ['name' => 'upload-setting', 'icon' => 'am-icon-tasks'],
                ],
            ],

            [
                'name'     => 'account',
                'icon'     => 'am-icon-gear',
                'children' => [
                    ['name' => 'account-setting', 'icon' => 'am-icon-home','route' => 'admin.account.index'],
                ],
            ],

            [
                'name'     => 'goods',
                'icon'     => 'am-icon-gift',
                'children' => [
                    ['name' => 'goods-category', 'icon' => 'am-icon-file', 'route' => 'admin.goods.category'],
                    ['name' => 'goods-brand', 'icon' => 'am-icon-file', 'route' => 'admin.goods.brand.index'],
                    ['name' => 'goods-goods', 'icon' => 'am-icon-file', 'route' => 'admin.goods.manage.index'],
                ],
            ],

            /*['name' => 'store', 'icon' => 'am-icon-bank'],*/
            [
                'name'     => 'member',
                'icon'     => 'am-icon-group',
                'children' => [
                    ['name' => 'member-purchaser', 'icon' => 'am-icon-file', 'route' => 'admin.provider.index'],
                    ['name' => 'member-provider', 'icon' => 'am-icon-file', 'route' => 'admin.purchaser.index'],
//                    ['name' => 'member-relationship', 'icon' => 'am-icon-file'],
                ],
            ],

            [
                'name'     => 'business',
                'icon'     => 'am-icon-shopping-cart',
                'children' => [
                    ['name' => 'business-supply-info', 'icon' => 'am-icon-file', 'route' => 'admin.trade.leads.index'],
                    ['name' => 'business-order-supply', 'icon' => 'am-icon-file', 'route' => 'admin.trade.order.index'],

                ],
            ],


            //TODO 待调整
            [
                'name'     => 'site',
                'icon'     => 'am-icon-sitemap',
                'children' => [
                    ['name' => 'site-category', 'icon' => 'am-icon-archive', 'route' => 'admin.category.index'],
                    ['name' => 'site-article', 'icon' => 'am-icon-file', 'route' => 'admin.article.index'],
//                    ['name' => 'advertisement', 'icon' => 'am-icon-file', 'route' => ''],
//                    ['name' => 'page-nav', 'icon' => 'am-icon-file', 'route' => ''],
                    ['name' => 'recommend', 'icon' => 'am-icon-archive', 'route' => 'admin.merchant.index'],
                    ['name' => 'hot-words', 'icon' => 'am-icon-archive', 'route' => 'admin.hot.word.index'],
//                    ['name' => 'cooperation', 'icon' => 'am-icon-file', 'route' => ''],

                ],
            ],

            [
                'name'     => 'manage',
                'icon'     => 'am-icon-tasks',
                'children' => [
                    ['name' => 'manage-logistics-price', 'icon' => 'am-icon-archive', 'route' => 'admin.logistics.enquiry.index'],

                ],
            ],

            [
                'name'     => 'authority',
                'icon'     => 'am-icon-tasks',
                'children' => [
                    ['name' => 'admin-management', 'icon' => 'am-icon-archive', 'route' => 'admin.admin.index'],
                    ['name' => 'admin-group-management', 'icon' => 'am-icon-archive', 'route' => 'admin.role.index'],

                ],
            ],

//            ['name' => 'statistics', 'icon' => 'am-icon-pie-chart'],
//            ['name' => 'mobile', 'icon' => 'am-icon-mobile'],
        ];


        foreach ($nav as $key => $create) {
            $children = [];

            if (isset($create['children'])) {
                $children = $create['children'];
                unset($create['children']);
            }

            $m = \App\B2BProject\Admin\AdminPanelNav::create($create);

            foreach ($children as $child) {
                $m->children()->save(\App\B2BProject\Admin\AdminPanelNav::create($child));
            }
        }
    }
}
